package com.sgy.spring_data_jpa.dao;

import com.sgy.spring_data_jpa.pojo.Resume;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * JpaRepository：封装了基本的sql接口
 * JpaSpecificationExecutor：封装了复杂的sql接口
 */
public interface ResumeDao extends JpaRepository<Resume,Integer>, JpaSpecificationExecutor<Resume> {

    @Query("from Resume where id=?1")
    public List<Resume> findByJpql(Integer id);

    /**
     * 使用原生sql语句查询，需要将nativeQuery设置为true
     * @param id
     * @return
     */
    @Query(value = "select * from tb_resume where id = ?1", nativeQuery = true)
    public List<Resume> findBySql(Integer id);

    public List<Resume> findByNameLikeAndAddress(String name, String address);
}
